home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / think / AmigaGnuChess.lha / chess / src.lha / src / dspcom.c < prev    next >
C/C++ Source or Header  |  1992-09-07  |  30KB  |  1,324 lines

  1. /*
  2.  * dspcom.c - C source for GNU CHESS
  3.  *
  4.  * Copyright (c) 1988,1989,1990 John Stanback
  5.  * Copyright (c) 1992 Free Software Foundation
  6.  *
  7.  * This file is part of GNU CHESS.
  8.  *
  9.  * GNU Chess is free software; you can redistribute it and/or modify
  10.  * it under the terms of the GNU General Public License as published by
  11.  * the Free Software Foundation; either version 2, or (at your option)
  12.  * any later version.
  13.  *
  14.  * GNU Chess is distributed in the hope that it will be useful,
  15.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17.  * GNU General Public License for more details.
  18.  *
  19.  * You should have received a copy of the GNU General Public License
  20.  * along with GNU Chess; see the file COPYING.  If not, write to
  21.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  */
  23. #include "gnuchess.h"
  24. #include "ataks.h"
  25. extern short Mwpawn[64], Mbpawn[64], Mknight[2][64], Mbishop[2][64];
  26. extern char *version, *patchlevel;
  27. char mvstr[4][6];
  28. char *InPtr;
  29.  
  30.  
  31. #include <ctype.h>
  32. #include <signal.h>
  33. #ifdef MSDOS
  34. #include <dos.h>
  35. #include <conio.h>
  36. #include <stdlib.h>
  37. #include <string.h>
  38. #include <time.h>
  39. #else
  40. #ifndef AMIGA
  41. #include <sys/param.h>
  42. #include <sys/types.h>
  43. #include <sys/file.h>
  44. #include <sys/ioctl.h>
  45. #define WarnMessage ShowMessage
  46. #else
  47. #include <sys/types.h>
  48. extern int get_command;
  49. #endif /* AMIGA */
  50. #endif /* MSDOS */
  51.  
  52. void
  53. algbr (short int f, short int t, short int flag)
  54.  
  55.  
  56. /*
  57.  * Generate move strings in different formats.
  58.  */
  59.  
  60. {
  61.   int m3p;
  62.  
  63.   if (f != t)
  64.     {
  65.       /* algebraic notation */
  66.       mvstr[0][0] = cxx[column (f)];
  67.       mvstr[0][1] = rxx[row (f)];
  68.       mvstr[0][2] = cxx[column (t)];
  69.       mvstr[0][3] = rxx[row (t)];
  70.       mvstr[0][4] = mvstr[3][0] = '\0';
  71.       if (((mvstr[1][0] = pxx[board[f]]) == 'P') || (flag & promote))
  72.     {
  73.       if (mvstr[0][0] == mvstr[0][2])    /* pawn did not eat */
  74.         {
  75.           mvstr[2][0] = mvstr[1][0] = mvstr[0][2];    /* to column */
  76.           mvstr[2][1] = mvstr[1][1] = mvstr[0][3];    /* to row */
  77.           m3p = 2;
  78.         }
  79.       else
  80.         /* pawn ate */
  81.         {
  82.           mvstr[2][0] = mvstr[1][0] = mvstr[0][0];    /* column */
  83.           mvstr[2][1] = mvstr[1][1] = mvstr[0][2];    /* to column */
  84.           mvstr[2][2] = mvstr[0][3];
  85.           m3p = 3;        /* to row */
  86.         }
  87.       if (flag & promote)
  88.         {
  89.           mvstr[0][4] = mvstr[1][2] = mvstr[2][m3p] = qxx[flag & pmask];
  90.           mvstr[0][5] = mvstr[1][3] = mvstr[2][m3p + 1] = mvstr[3][0] = '\0';
  91. #ifdef CHESSTOOL
  92.           mvstr[3][0] = mvstr[0][0];    /* Allow e7e8 for chesstool */
  93.           mvstr[3][1] = mvstr[0][1];
  94.           mvstr[3][2] = mvstr[0][2];
  95.           mvstr[3][3] = mvstr[0][3];
  96.           mvstr[3][4] = '\0';
  97. #endif
  98.         }
  99.       mvstr[2][m3p] = mvstr[1][2] = '\0';
  100.     }
  101.       else
  102.     /* not a pawn */
  103.     {
  104.       mvstr[2][0] = mvstr[1][0];
  105.       mvstr[2][1] = mvstr[0][1];
  106.       mvstr[2][2] = mvstr[1][1] = mvstr[0][2];    /* to column */
  107.       mvstr[2][3] = mvstr[1][2] = mvstr[0][3];    /* to row */
  108.       mvstr[2][4] = mvstr[1][3] = '\0';
  109.       strcpy (mvstr[3], mvstr[2]);
  110.       mvstr[3][1] = mvstr[0][0];
  111.       if (flag & cstlmask)
  112.         {
  113.           if (t > f)
  114.         {
  115.           strcpy (mvstr[1], CP[5]);
  116.           strcpy (mvstr[2], CP[7]);
  117.         }
  118.           else
  119.         {
  120.           strcpy (mvstr[1], CP[6]);
  121.           strcpy (mvstr[2], CP[8]);
  122.         }
  123.         }
  124.     }
  125.     }
  126.   else
  127.     mvstr[0][0] = mvstr[1][0] = mvstr[2][0] = mvstr[3][0] = '\0';
  128. }
  129.  
  130.  
  131. int
  132. VerifyMove (char *s, short int iop,  unsigned short int *mv)
  133.  
  134. /*
  135.  * Compare the string 's' to the list of legal moves available for the
  136.  * opponent. If a match is found, make the move on the board.
  137.  */
  138.  
  139. {
  140.   static short pnt, tempb, tempc, tempsf, tempst, cnt;
  141.   static struct leaf xnode;
  142.   struct leaf *node;
  143.  
  144.   *mv = 0;
  145.   if (iop == 2)
  146.     {
  147.       UnmakeMove (opponent, &xnode, &tempb, &tempc, &tempsf, &tempst);
  148.       return (false);
  149.     }
  150.   cnt = 0;
  151.   MoveList (opponent, 2);
  152.   pnt = TrPnt[2];
  153.   while (pnt < TrPnt[3])
  154.     {
  155.       node = &Tree[pnt++];
  156.       algbr (node->f, node->t, (short) node->flags);
  157.       if (strcmp (s, mvstr[0]) == 0 || strcmp (s, mvstr[1]) == 0 ||
  158.       strcmp (s, mvstr[2]) == 0 || strcmp (s, mvstr[3]) == 0)
  159.     {
  160.       cnt++;
  161.       xnode = *node;
  162.     }
  163.     }
  164.   if (cnt == 1)
  165.     {
  166.       MakeMove (opponent, &xnode, &tempb, &tempc, &tempsf, &tempst, &INCscore);
  167.       if (SqAtakd (PieceList[opponent][0], computer))
  168.     {
  169.       UnmakeMove (opponent, &xnode, &tempb, &tempc, &tempsf, &tempst);
  170. #if defined CHESSTOOL
  171.       printz (CP[15]);
  172. #else
  173. #ifdef NONDSP
  174. /* Illegal move in check */
  175.       printz (CP[77]);
  176.       printz ("\n");
  177. #else
  178. /* Illegal move in check */
  179.       WarnMessage (CP[77]);
  180. #endif
  181. #endif /* CHESSTOOL */
  182.       return (false);
  183.     }
  184.       else
  185.     {
  186.       if (iop == 1)
  187.         return (true);
  188.       UpdateDisplay (xnode.f, xnode.t, 0, (short) xnode.flags);
  189.       if ((board[xnode.t] == pawn)
  190.           || (xnode.flags & capture)
  191.           || (xnode.flags & cstlmask))
  192.         {
  193.           Game50 = GameCnt;
  194.           ZeroRPT ();
  195.         }
  196.       GameList[GameCnt].depth = GameList[GameCnt].score = 0;
  197.       GameList[GameCnt].nodes = 0;
  198.       ElapsedTime (1);
  199.       GameList[GameCnt].time = et;
  200.       if (TCflag)
  201.         {
  202.           TimeControl.clock[opponent] -= et;
  203.           --TimeControl.moves[opponent];
  204.         }
  205.       *mv = (xnode.f << 8) | xnode.t;
  206.       algbr (xnode.f, xnode.t, false);
  207.       return (true);
  208.     }
  209.     }
  210. #if defined CHESSTOOL
  211.   printz (CP[78]);
  212. #else
  213. #ifdef NONDSP
  214. /* Illegal move */
  215.   printz (CP[75], s);
  216. #ifdef DEBUG8
  217.   if (1)
  218.     {
  219.       FILE *D;
  220.       int r, c, l;
  221.       extern unsigned short int PrVar[];
  222.       D = fopen ("/tmp/DEBUG", "a+");
  223.       pnt = TrPnt[2];
  224.       fprintf (D, "resp = %d\n", ResponseTime);
  225.       fprintf (D, "iop = %d\n", iop);
  226.       fprintf (D, "matches = %d\n", cnt);
  227.       algbr (hint >> 8, hint & 0xff, (short) 0);
  228.       fprintf (D, "hint %s\n", mvstr[0]);
  229.       fprintf (D, "inout move is %s\n", s);
  230.       for (r = 1; PrVar[r]; r++)
  231.     {
  232.       algbr (PrVar[r] >> 8, PrVar[r] & 0xff, (short) 0);
  233.       fprintf (D, " %s", mvstr[0]);
  234.     }
  235.       fprintf (D, "\n");
  236.       fprintf (D, "legal move are \n");
  237.       while (pnt < TrPnt[3])
  238.     {
  239.       node = &Tree[pnt++];
  240.       algbr (node->f, node->t, (short) node->flags);
  241.       fprintf (D, "%s %s %s %s\n", mvstr[0], mvstr[1], mvstr[2], mvstr[3]);
  242.     }
  243.       fprintf (D, "\n current board is\n");
  244.       for (r = 7; r >= 0; r--)
  245.     {
  246.       for (c = 0; c <= 7; c++)
  247.         {
  248.           l = locn (r, c);
  249.           if (color[l] == neutral)
  250.         fprintf (D, " -");
  251.           else if (color[l] == white)
  252.         fprintf (D, " %c", qxx[board[l]]);
  253.           else
  254.         fprintf (D, " %c", pxx[board[l]]);
  255.         }
  256.       fprintf (D, "\n");
  257.     }
  258.       fprintf (D, "\n");
  259.       fclose (D);
  260.       abort ();
  261.     }
  262. #endif
  263. #else
  264. /* Illegal move */
  265.   WarnMessage (CP[76]);
  266. #endif
  267. #endif /* CHESSTOOL */
  268. #if !defined CHESSTOOL && !defined XBOARD
  269.   if (cnt > 1)
  270.     WarnMessage (CP[32]);
  271. #endif /* CHESSTOOL */
  272.   return (false);
  273. }
  274.  
  275. int
  276. parser (char *f, int side)
  277. {
  278.   int c1, r1, c2, r2;
  279.  
  280.   if (f[4] == 'o')
  281.     if (side == black)
  282.       return 0x3C3A;
  283.     else
  284.       return 0x0402;
  285.   else if (f[0] == 'o')
  286.     if (side == black)
  287.       return 0x3C3E;
  288.     else
  289.       return 0x0406;
  290.   else
  291.     {
  292.       c1 = f[0] - 'a';
  293.       r1 = f[1] - '1';
  294.       c2 = f[2] - 'a';
  295.       r2 = f[3] - '1';
  296.       return (locn (r1, c1) << 8) | locn (r2, c2);
  297.     }
  298.   /*NOTREACHED*/
  299. }
  300.  
  301. void
  302. GetGame (void)
  303. {
  304.   FILE *fd;
  305.   char fname[256], *p;
  306.   int c, i, j;
  307.   short sq;
  308. /* enter file name */
  309.   ShowMessage (CP[63]);
  310.   scanz ("%s", fname);
  311. /* chess.000 */
  312.   if (fname[0] == '\0')
  313.     strcpy (fname, CP[137]);
  314.   if ((fd = fopen (fname, "r")) != NULL)
  315.     {
  316.       NewGame ();
  317.       fgets (fname, 256, fd);
  318.       computer = opponent = white;
  319.       InPtr = fname;
  320.       skip ();
  321.       if (*InPtr == 'c')
  322.     computer = black;
  323.       else
  324.     opponent = black;
  325.       skip ();
  326.       skip ();
  327.       skip ();
  328.       Game50 = atoi (InPtr);
  329.       fgets (fname, 256, fd);
  330.       InPtr = &fname[14];
  331.       castld[white] = ((*InPtr == CP[214][0]) ? true : false);
  332.       skip ();
  333.       skip ();
  334.       castld[black] = ((*InPtr == CP[214][0]) ? true : false);
  335.       fgets (fname, 256, fd);
  336.       InPtr = &fname[11];
  337.       skipb ();
  338.       TCflag = atoi (InPtr);
  339.       skip ();
  340.       InPtr += 14;
  341.       skipb ();
  342.       OperatorTime = atoi (InPtr);
  343.       fgets (fname, 256, fd);
  344.       InPtr = &fname[11];
  345.       skipb ();
  346.       TimeControl.clock[white] = atoi (InPtr);
  347.       skip ();
  348.       skip ();
  349.       TimeControl.moves[white] = atoi (InPtr);
  350.       fgets (fname, 256, fd);
  351.       InPtr = &fname[11];
  352.       skipb ();
  353.       TimeControl.clock[black] = atoi (InPtr);
  354.       skip ();
  355.       skip ();
  356.       TimeControl.moves[black] = atoi (InPtr);
  357.       fgets (fname, 256, fd);
  358.       for (i = 7; i > -1; i--)
  359.     {
  360.       fgets (fname, 256, fd);
  361.       p = &fname[2];
  362.       InPtr = &fname[11];
  363.       skipb ();
  364.       for (j = 0; j < 8; j++)
  365.         {
  366.           sq = i * 8 + j;
  367.           if (*p == '.')
  368.         {
  369.           board[sq] = no_piece;
  370.           color[sq] = neutral;
  371.         }
  372.           else
  373.         {
  374.           for (c = 0; c < 8; c++)
  375.             {
  376.               if (*p == pxx[c])
  377.             {
  378.               board[sq] = c;
  379.               color[sq] = black;
  380.             }
  381.             }
  382.           for (c = 0; c < 8; c++)
  383.             {
  384.               if (*p == qxx[c])
  385.             {
  386.               board[sq] = c;
  387.               color[sq] = white;
  388.             }
  389.             }
  390.         }
  391.           p++;
  392.           Mvboard[sq] = atoi (InPtr);
  393.           skip ();
  394.         }
  395.     }
  396.       GameCnt = 0;
  397.       flag.regularstart = true;
  398.       Book = BOOKFAIL;
  399.       fgets (fname, 256, fd);
  400.       fgets (fname, 256, fd);
  401.       fgets (fname, 256, fd);
  402.       while (fgets (fname, 256, fd))
  403.     {
  404.       struct GameRec *g;
  405.       int side = computer;
  406.  
  407.       side = side ^ 1;
  408.       ++GameCnt;
  409.       InPtr = fname;
  410.       skipb ();
  411.       g = &GameList[GameCnt];
  412.       g->gmove = parser (InPtr, side);
  413.       skip ();
  414.       g->score = atoi (InPtr);
  415.       skip ();
  416.       g->depth = atoi (InPtr);
  417.       skip ();
  418.       g->nodes = atoi (InPtr);
  419.       skip ();
  420.       g->time = atoi (InPtr);
  421.       skip ();
  422.       g->flags = c = atoi (InPtr);
  423.       skip ();
  424.       g->hashkey = strtol (InPtr, (char **) NULL, 16);
  425.       skip ();
  426.       g->hashbd = strtol (InPtr, (char **) NULL, 16);
  427.       g->piece = no_piece;
  428.       g->color = neutral;
  429.       if (c & (capture | cstlmask))
  430.         {
  431.           if (c & capture)
  432.         {
  433.           skip ();
  434.           for (c = 0; c < 8; c++)
  435.             if (pxx[c] == *InPtr)
  436.               break;
  437.           g->piece = c;
  438.         }
  439.           skip ();
  440.           g->color = ((*InPtr == CP[119][0]) ? black : white);
  441.         }
  442.     }
  443.       /* GameCnt--; */
  444.       if (TimeControl.clock[white] > 0)
  445.     TCflag = true;
  446.       fclose (fd);
  447.     }
  448.   else
  449.     WarnMessage (CP[48]);
  450.  
  451.   ZeroRPT ();
  452.   InitializeStats ();
  453.   UpdateDisplay (0, 0, 1, 0);
  454.   Sdepth = 0;
  455.   hint = 0;
  456. }
  457.  
  458. #ifndef AMIGA
  459. void
  460. GetXGame (void)
  461. {
  462.   FILE *fd;
  463.   char fname[256], *p;
  464.   int c, i, j;
  465.   short sq;
  466. /* Enter file name */
  467.   ShowMessage (CP[63]);
  468.   scanz ("%s", fname);
  469.   if (fname[0] == '\0')
  470. /* xboard.position.read*/
  471.     strcpy (fname, CP[205]);
  472.   if ((fd = fopen (fname, "r")) != NULL)
  473.     {
  474.       NewGame ();
  475.       flag.regularstart = false;
  476.       Book = false;
  477.       fgets (fname, 256, fd);
  478.       fname[6] = '\0';
  479.       if (strcmp (fname, CP[206]))
  480.     return;
  481.       fgets (fname, 256, fd);
  482.       fgets (fname, 256, fd);
  483.       for (i = 7; i > -1; i--)
  484.     {
  485.       fgets (fname, 256, fd);
  486.       p = fname;
  487.       for (j = 0; j < 8; j++)
  488.         {
  489.           sq = i * 8 + j;
  490.           if (*p == '.')
  491.         {
  492.           board[sq] = no_piece;
  493.           color[sq] = neutral;
  494.         }
  495.           else
  496.         {
  497.           for (c = 0; c < 8; c++)
  498.             {
  499.               if (*p == qxx[c])
  500.             {
  501.               board[sq] = c;
  502.               color[sq] = black;
  503.             }
  504.             }
  505.           for (c = 0; c < 8; c++)
  506.             {
  507.               if (*p == pxx[c])
  508.             {
  509.               board[sq] = c;
  510.               color[sq] = white;
  511.             }
  512.             }
  513.         }
  514.           p += 2;
  515.         }
  516.     }
  517.       fclose (fd);
  518.     }
  519.   else
  520.     WarnMessage (CP[48]);
  521.   ZeroRPT ();
  522.   InitializeStats ();
  523.   UpdateDisplay (0, 0, 1, 0);
  524.   Sdepth = 0;
  525.   hint = 0;
  526. }
  527. #endif /* AMIGA */
  528.  
  529. void
  530. SaveGame (void)
  531. {
  532.   FILE *fd;
  533.   char fname[256];
  534.   short sq, i, c, f, t;
  535.   char p;
  536.  
  537.   if (savefile[0])
  538.     strcpy (fname, savefile);
  539.   else
  540.     {
  541. /* Enter file name*/
  542.       ShowMessage (CP[63]);
  543.       scanz ("%s", fname);
  544.     }
  545.  
  546.   if (fname[0] == '\0')
  547. /* chess.000 */
  548.     strcpy (fname, CP[137]);
  549.   if ((fd = fopen (fname, "w")) != NULL)
  550.     {
  551.       char *b, *w;
  552.  
  553.       b = w = CP[74];
  554.       if (computer == black)
  555.     b = CP[141];
  556.       if (computer == white)
  557.     w = CP[141];
  558.       fprintf (fd, CP[37], b, w, Game50);
  559.       fprintf (fd, CP[42], castld[white] ? CP[214] : CP[215], castld[black] ? CP[214] : CP[215]);
  560.       fprintf (fd, CP[111], TCflag, OperatorTime);
  561.       fprintf (fd, CP[117],
  562.            TimeControl.clock[white], TimeControl.moves[white],
  563.            TimeControl.clock[black], TimeControl.moves[black]);
  564.       for (i = 7; i > -1; i--)
  565.     {
  566.       fprintf (fd, "%1d ", i + 1);
  567.       for (c = 0; c < 8; c++)
  568.         {
  569.           sq = i * 8 + c;
  570.           switch (color[sq])
  571.         {
  572.         case black:
  573.           p = pxx[board[sq]];
  574.           break;
  575.         case white:
  576.           p = qxx[board[sq]];
  577.           break;
  578.         default:
  579.           p = '.';
  580.         }
  581.           fprintf (fd, "%c", p);
  582.         }
  583.       for (f = i * 8; f < i * 8 + 8; f++)
  584.         fprintf (fd, " %d", Mvboard[f]);
  585.       fprintf (fd, "\n");
  586.     }
  587.       fprintf (fd, "  %s\n", cxx);
  588.       fprintf (fd, CP[126]);
  589.       for (i = 1; i <= GameCnt; i++)
  590.     {
  591.       struct GameRec *g = &GameList[i];
  592.  
  593.       f = g->gmove >> 8;
  594.       t = (g->gmove & 0xFF);
  595.       algbr (f, t, g->flags);
  596.       fprintf (fd, "%s %5d %5d %7ld %5d %5d  %#08lx %#08lx  %c   %s\n",
  597.            mvstr[0], g->score, g->depth,
  598.            g->nodes, g->time, g->flags, g->hashkey, g->hashbd,
  599.        pxx[g->piece], ((g->color == 2) ? "     " : ColorStr[g->color]));
  600.     }
  601.       fclose (fd);
  602. /* Game saved */
  603.       ShowMessage (CP[70]);
  604.     }
  605.   else
  606.     /*ShowMessage ("Could not open file");*/
  607.     WarnMessage (CP[48]);
  608. }
  609.  
  610. void
  611. ListGame (void)
  612. {
  613.   FILE *fd;
  614.   short i, f, t;
  615.   long when;
  616.   char fname[256], dbuf[256];
  617.  
  618.   if (listfile[0])
  619.     strcpy (fname, listfile);
  620.   else
  621.     {
  622. #ifdef MSDOS
  623.       sprintf (fname, "chess.lst");
  624. #else
  625.       time (&when);
  626.       strncpy (dbuf, ctime (&when), 20);
  627.       dbuf[7] = '\0';
  628.       dbuf[10] = '\0';
  629.       dbuf[13] = '\0';
  630.       dbuf[16] = '\0';
  631.       dbuf[19] = '\0';
  632. /* use format "CLp16.Jan01-020304B" when patchlevel is 16,
  633.    date is Jan 1
  634.    time is 02:03:04
  635.    program played black */
  636.       sprintf (fname, "CLp%s.%s%s-%s%s%s%c", patchlevel, dbuf + 4, dbuf + 8, dbuf + 11, dbuf + 14, dbuf + 17, ColorStr[computer][0]);
  637.       /* replace space padding with 0 */
  638.       for (i = 0; fname[i] != '\0'; i++)
  639.     if (fname[i] == ' ')
  640.       fname[i] = '0';
  641. #endif /* MSDOS */
  642.     }
  643.   fd = fopen (fname, "w");
  644.   if (!fd)
  645.     {
  646.       fprintf (stderr, CP[219], fname);
  647.       exit (1);
  648.     }
  649.   /*fprintf (fd, "gnuchess game %d\n", u);*/
  650.   fprintf (fd, CP[161], patchlevel);
  651.   fprintf (fd, CP[10]);
  652.   fprintf (fd, CP[11]);
  653.   for (i = 1; i <= GameCnt; i++)
  654.     {
  655.       f = GameList[i].gmove >> 8;
  656.       t = (GameList[i].gmove & 0xFF);
  657.       algbr (f, t, GameList[i].flags);
  658.       fprintf (fd, "%5s  %5d     %2d %7ld %5d", mvstr[0],
  659.            GameList[i].score, GameList[i].depth,
  660.            GameList[i].nodes, GameList[i].time);
  661.       if ((i % 2) == 0)
  662.     {
  663.       fprintf (fd, "\n");
  664. #ifdef DEBUG40
  665.       if (computer == black)
  666.         fprintf (fd, " %d %d %d %d %d %d %d\n",
  667.              GameList[i].d1,
  668.              GameList[i].d2,
  669.              GameList[i].d3,
  670.              GameList[i].d4,
  671.              GameList[i].d5,
  672.              GameList[i].d6,
  673.              GameList[i].d7);
  674.       else
  675.         fprintf (fd, " %d %d %d %d %d %d %d\n",
  676.              GameList[i - 1].d1,
  677.              GameList[i - 1].d2,
  678.              GameList[i - 1].d3,
  679.              GameList[i - 1].d4,
  680.              GameList[i - 1].d5,
  681.              GameList[i - 1].d6,
  682.              GameList[i - 1].d7);
  683. #endif
  684.     }
  685.       else
  686.     fprintf (fd, "         ");
  687.     }
  688.   fprintf (fd, "\n\n");
  689.   if (GameList[GameCnt].flags & draw)
  690.     {
  691.       fprintf (fd, CP[54], DRAW);
  692.     }
  693.   else if (GameList[GameCnt].score == -9999)
  694.     {
  695.       fprintf (fd, "%s\n", ColorStr[player ]);
  696.     }
  697.   else if (GameList[GameCnt].score == 9998)
  698.     {
  699.       fprintf (fd, "%s\n", ColorStr[player ^ 1]);
  700.     }
  701.   fclose (fd);
  702. }
  703.  
  704. void
  705. Undo (void)
  706.  
  707. /*
  708.  * Undo the most recent half-move.
  709.  */
  710.  
  711. {
  712.   short f, t;
  713.   f = GameList[GameCnt].gmove >> 8;
  714.   t = GameList[GameCnt].gmove & 0xFF;
  715.   if (board[t] == king && distance (t, f) > 1)
  716.     (void) castle (GameList[GameCnt].color, f, t, 2);
  717.   else
  718.     {
  719.       /* Check for promotion: */
  720.       if (GameList[GameCnt].flags & promote)
  721.     {
  722.       board[t] = pawn;
  723.     }
  724.       board[f] = board[t];
  725.       color[f] = color[t];
  726.       board[t] = GameList[GameCnt].piece;
  727.       color[t] = GameList[GameCnt].color;
  728.       if (color[t] != neutral)
  729.     Mvboard[t]--;
  730.       Mvboard[f]--;
  731.     }
  732.   if (GameList[GameCnt].flags & epmask)
  733.     EnPassant (otherside[color[f]], f, t, 2);
  734.   else
  735.     InitializeStats ();
  736.   if (TCflag && (TCmoves>1))
  737.     ++TimeControl.moves[color[f]];
  738.   hashkey = GameList[GameCnt].hashkey;
  739.   hashbd = GameList[GameCnt].hashbd;
  740.   GameCnt--;
  741.   computer = computer ^ 1;
  742.   opponent = opponent ^ 1;
  743.   flag.mate = false;
  744.   Sdepth = 0;
  745.   player = player ^ 1;
  746.   ShowSidetoMove ();
  747.   UpdateDisplay (0, 0, 1, 0);
  748.   if (flag.regularstart)
  749.     Book = BOOKFAIL;
  750. }
  751.  
  752. void
  753.  TestSpeed (void (*f) (short int side, short int ply), unsigned j)
  754. {
  755.   short i;
  756.   long cnt, rate, t1, t2;
  757.  
  758.   t1 = time (0);
  759.   for (i = 0; i < j; i++)
  760.     {
  761.       f (opponent, 2);
  762.     }
  763.   t2 = time (0);
  764.   cnt = j * (TrPnt[3] - TrPnt[2]);
  765.   if (t2 - t1)
  766.     et = (t2 - t1) * 100;
  767.   else
  768.     et = 1;
  769.   rate = (et) ? (cnt / et) : 0;
  770.   /*printz ("Nodes= %ld Nodes/sec= %ld\n", cnt, rate);*/
  771. #ifdef NONDSP
  772.   printz (CP[91], cnt, rate*100);
  773. #ifdef DEBUG9
  774.   for (j = TrPnt[2]; j < TrPnt[3]; j++)
  775.     {
  776.       struct leaf *node = &Tree[j];
  777.       algbr (node->f, node->t, node->flags);
  778.       printf ("%s %s %s %s %d %x\n", mvstr[0], mvstr[1], mvstr[2], mvstr[3],node->score,node->flags);
  779.     }
  780. #endif
  781. #else
  782.   ShowNodeCnt (cnt);
  783. #endif
  784. }
  785.  
  786. void
  787.  TestPSpeed (short int (*f) (short int side), unsigned j)
  788. {
  789.   short i;
  790.   long cnt, rate, t1, t2;
  791.   short int t;
  792.  
  793.   t1 = time (0);
  794.   for (i = 0; i < j; i++)
  795.     {
  796.       (void) f (opponent);
  797.     }
  798.   t2 = time (0);
  799.   cnt = j;
  800.   if (t2 - t1)
  801.     et = (t2 - t1) * 100;
  802.   else
  803.     et = 1;
  804.   rate = (et) ? (cnt / et) : 0;
  805.   /*printz ("Nodes= %ld Nodes/sec= %ld\n", cnt, rate);*/
  806. #ifdef NONDSP
  807.   printz (CP[91], cnt, rate*100);
  808. #else
  809.   ShowNodeCnt (cnt);
  810. #endif
  811. }
  812.  
  813.  
  814. void
  815. SetMachineTime (char *s)
  816. {
  817.   char *time;
  818.   int m, t;
  819.   time = &s[strlen (CP[197])];
  820.   t = strtol (time, &time, 10);
  821.   m = strtol (time, &time, 10);
  822.   if (t)
  823.     TimeControl.clock[computer] = t;
  824.   if (m)
  825.     TimeControl.moves[computer] = m;
  826. #ifdef XBOARD
  827.   printz (CP[222], m, t);
  828. #endif
  829. }
  830.  
  831.  
  832. void
  833. InputCommand (void)
  834.  
  835. /*
  836.  * Process the users command. If easy mode is OFF (the computer is thinking
  837.  * on opponents time) and the program is out of book, then make the 'hint'
  838.  * move on the board and call SelectMove() to find a response. The user
  839.  * terminates the search by entering ^C (quit siqnal) before entering a
  840.  * command. If the opponent does not make the hint move, then set Sdepth to
  841.  * zero.
  842.  */
  843.  
  844. {
  845.   int i = 0;
  846.   short have_shown_prompt = false;
  847.   short ok, tmp;
  848.   unsigned short mv;
  849.   char s[80], sx[80];
  850.  
  851. #if defined CHESSTOOL
  852.   short normal = false;
  853.  
  854. #endif
  855.  
  856.   ok = flag.quit = false;
  857.   player = opponent;
  858.   ft = 0;
  859.   if (hint > 0 && !flag.easy && !flag.force)
  860.     if ((board[hint >> 8] != pawn) || ((row (hint & 0xFF) != 0) && (row (hint & 0xFF) != 7)))
  861.       {
  862.     fflush (stdout);
  863.     time0 = time ((long *) 0);
  864.     algbr ((short) hint >> 8, (short) hint & 0xFF, false);
  865.     strcpy (s, mvstr[0]);
  866.     tmp = epsquare;
  867. #ifdef DEBUG12
  868.     if (1)
  869.       {
  870.         FILE *D;
  871.         int r, c, l;
  872.         extern unsigned short int PrVar[];
  873.         extern struct leaf rootnode;
  874.         D = fopen ("/tmp/DEBUGA", "a+");
  875.         fprintf (D, "score = %d\n", rootnode.score);
  876.         fprintf (D, "inout move is %s\n", s);
  877.         for (r = 1; PrVar[r]; r++)
  878.           {
  879.         algbr (PrVar[r] >> 8, PrVar[r] & 0xff, (short) 0);
  880.         fprintf (D, " %s", mvstr[0]);
  881.           }
  882.         fprintf (D, "\n current board is\n");
  883.         for (r = 7; r >= 0; r--)
  884.           {
  885.         for (c = 0; c <= 7; c++)
  886.           {
  887.             l = locn (r, c);
  888.             if (color[l] == neutral)
  889.               fprintf (D, " -");
  890.             else if (color[l] == white)
  891.               fprintf (D, " %c", qxx[board[l]]);
  892.             else
  893.               fprintf (D, " %c", pxx[board[l]]);
  894.           }
  895.         fprintf (D, "\n");
  896.           }
  897.         fprintf (D, "\n");
  898.         fclose (D);
  899.       }
  900. #endif
  901. #if !defined CHESSTOOL
  902.     if (flag.post)
  903.       GiveHint ();
  904. #endif
  905.     if (VerifyMove (s, 1, &mv))
  906.       {
  907.         Sdepth = 0;
  908. #ifdef QUIETBACKGROUND
  909. #ifdef NONDSP
  910.         PromptForMove ();
  911. #else
  912.         ShowSidetoMove ();
  913.         ShowPrompt ();
  914. #endif
  915.         have_shown_prompt = true;
  916. #endif /* QUIETBACKGROUND */
  917.         SelectMove (computer, 2);
  918.         VerifyMove (s, 2, &mv);
  919.         Sdepth = 0;
  920.       }
  921.     ft = (time ((long *) 0) - time0) * 100;
  922.     epsquare = tmp;
  923.       }
  924.   while (!(ok || flag.quit))
  925.     {
  926. #if defined CHESSTOOL
  927.       normal = false;
  928. #endif
  929.       player = opponent;
  930. #ifdef QUIETBACKGROUND
  931.       if (!have_shown_prompt)
  932.     {
  933. #endif /* QUIETBACKGROUND */
  934. #ifdef NONDSP
  935.       PromptForMove ();
  936. #else
  937.       ShowSidetoMove ();
  938.       ShowPrompt ();
  939. #endif
  940. #ifdef QUIETBACKGROUND
  941.     }
  942.       have_shown_prompt = false;
  943. #endif /* QUIETBACKGROUND */
  944. #ifdef NONDSP
  945.       s[0] = sx[0] = '\0';
  946.       while (!sx[0])
  947.     i = (int) gets (sx);
  948. #else
  949. #ifndef AMIGA
  950.       fflush (stdout);
  951.       i = (int) getstr (sx);
  952. #else
  953.       cursoron();
  954. #ifndef NON_GFX
  955.     get_command = true;
  956. #endif
  957.       i = (int) getstr (sx);
  958. #ifndef NON_GFX
  959.     get_command = false;
  960. #endif
  961.       cursoroff();
  962. #endif /* AMIGA */
  963. #endif
  964.       ClearMessage();
  965.       sscanf (sx, "%s", s);
  966.       if (i == EOF)
  967.     ExitChess ();
  968.       if (s[0] == '\0')
  969.     continue;
  970.       if (stricmp (s, CP[131]) == 0)    /*bd*/
  971.     {
  972. #if defined CHESSTOOL || defined XBOARD
  973.       chesstool = 0;
  974. #endif /* CHESSTOOL */
  975.       ClrScreen ();
  976.       UpdateDisplay (0, 0, 1, 0);
  977. #if defined CHESSTOOL || defined XBOARD
  978.       chesstool = 1;
  979. #endif /* CHESSTOOL */
  980.     }
  981.       else if (stricmp (s, CP[129]) == 0) /* noop */ ;    /*alg*/
  982.       else if ((stricmp (s, CP[180]) == 0) || (stricmp (s, CP[216]) == 0))    /* quit exit*/
  983.     flag.quit = true;
  984.       else if (stricmp (s, CP[178]) == 0)    /*post*/
  985.     {
  986.       flag.post = !flag.post;
  987.     }
  988.       else if ((stricmp (s, CP[191]) == 0) || (stricmp (s, CP[154]) == 0))    /*set edit*/
  989.     EditBoard ();
  990. #ifdef NONDSP
  991.       else if (stricmp (s, CP[190]) == 0)    /*setup*/
  992.     SetupBoard ();
  993. #endif
  994.       else if (stricmp (s, CP[156]) == 0)    /*first*/
  995.     {
  996. #if defined CHESSTOOL
  997.       computer = white;
  998.       opponent = black;
  999.       flag.force = false;
  1000.       Sdepth = 0;
  1001. #endif /* CHESSTOOL */
  1002.       ok = true;
  1003.     }
  1004.       else if (stricmp (s, CP[162]) == 0)    /*go*/
  1005.     {
  1006.       ok = true;
  1007.       flag.force = false;
  1008.       if (computer == white)
  1009.         {
  1010.           computer = black;
  1011.           opponent = white;
  1012.         }
  1013.       else
  1014.         {
  1015.           computer = white;
  1016.           opponent = black;
  1017.         }
  1018.       ShowPlayers();
  1019.     }
  1020.       else if (stricmp (s, CP[166]) == 0 || stricmp (s, "?") == 0)    /*help*/
  1021.     help ();
  1022.       else if (stricmp (s, CP[221]) == 0)    /*material*/
  1023.     flag.material = !flag.material;
  1024.       else if (stricmp (s, CP[157]) == 0)    /*force*/
  1025.     {flag.force = !flag.force; flag.bothsides = false;}
  1026.       else if (stricmp (s, CP[134]) == 0)    /*book*/
  1027.     Book = Book ? 0 : BOOKFAIL;
  1028.       else if (stricmp (s, CP[172]) == 0)    /*new*/
  1029.     {
  1030.       NewGame ();
  1031.       UpdateDisplay (0, 0, 1, 0);
  1032.     }
  1033.       else if (stricmp (s, CP[171]) == 0)    /*list*/
  1034.     ListGame ();
  1035.       else if (stricmp (s, CP[169]) == 0 || stricmp (s, CP[217]) == 0)    /*level clock*/
  1036.     SelectLevel ();
  1037.       else if (stricmp (s, CP[165]) == 0)    /*hash*/
  1038.     flag.hash = !flag.hash;
  1039.       else if (stricmp (s, CP[132]) == 0)    /*beep*/
  1040.     flag.beep = !flag.beep;
  1041.       else if (stricmp (s, CP[197]) == 0)    /*time*/
  1042.     {
  1043.       SetMachineTime (sx);
  1044.     }
  1045.       else if (stricmp (s, CP[33]) == 0)    /*Awindow*/
  1046.     ChangeAlphaWindow ();
  1047.       else if (stricmp (s, CP[39]) == 0)    /*Bwindow*/
  1048.     ChangeBetaWindow ();
  1049.       else if (stricmp (s, CP[183]) == 0)    /*rcptr*/
  1050.     flag.rcptr = !flag.rcptr;
  1051.       else if (stricmp (s, CP[168]) == 0)    /*hint*/
  1052.     GiveHint ();
  1053.       else if (stricmp (s, CP[135]) == 0)    /*both*/
  1054.     {
  1055.       flag.bothsides = !flag.bothsides;
  1056.           flag.force = false;
  1057.       Sdepth = 0;
  1058.       ElapsedTime (1);
  1059.       SelectMove (opponent, 1);
  1060.       ok = true;
  1061.     }
  1062.       else if (stricmp (s, CP[185]) == 0)    /*reverse*/
  1063.     {
  1064.       flag.reverse = !flag.reverse;
  1065.       ClrScreen ();
  1066.       UpdateDisplay (0, 0, 1, 0);
  1067.     }
  1068.       else if (stricmp (s, CP[195]) == 0)    /*switch*/
  1069.     {
  1070.       computer = computer ^ 1;
  1071.       opponent = opponent ^ 1;
  1072.       xwndw = (computer == white) ? WXWNDW : BXWNDW;
  1073.       flag.force = false;
  1074.       Sdepth = 0;
  1075.       ok = true;
  1076.       ShowPlayers();
  1077.     }
  1078.       else if (stricmp (s, CP[203]) == 0)    /*white*/
  1079.     {
  1080.       computer = black;
  1081.       opponent = white;
  1082.       xwndw = WXWNDW;
  1083.       flag.force = false;
  1084.       Sdepth = 0;
  1085.  
  1086.       /*
  1087.            * ok = true; don't automatically start with white command
  1088.            */
  1089.     }
  1090.       else if (stricmp (s, CP[133]) == 0)    /*black*/
  1091.     {
  1092.       computer = white;
  1093.       opponent = black;
  1094.       xwndw = BXWNDW;
  1095.       flag.force = false;
  1096.       Sdepth = 0;
  1097.  
  1098.       /*
  1099.            * ok = true; don't automatically start with black command
  1100.            */
  1101.     }
  1102.       else if (stricmp (s, CP[201]) == 0 && GameCnt > 0)    /*undo*/
  1103.     {
  1104.       Undo ();
  1105.     }
  1106.       else if (stricmp (s, CP[184]) == 0 && GameCnt > 1)    /*remove*/
  1107.     {
  1108.       Undo ();
  1109.       Undo ();
  1110.     }
  1111.       else if (stricmp (s, CP[160]) == 0)    /*get*/
  1112.     GetGame ();
  1113. #ifndef AMIGA
  1114.       else if (stricmp (s, CP[207]) == 0)    /*xget*/
  1115.     GetXGame ();
  1116. #endif
  1117.       else if (stricmp (s, CP[189]) == 0)    /*save*/
  1118.     SaveGame ();
  1119.       else if (stricmp (s, CP[151]) == 0)    /*depth*/
  1120.     ChangeSearchDepth ();
  1121. #ifdef DEBUG
  1122.       else if (stricmp (s, CP[147]) == 0)    /*debuglevel*/
  1123.     ChangeDbLev ();
  1124. #endif /* DEBUG */
  1125.       else if (stricmp (s, CP[164]) == 0)    /*hashdepth*/
  1126.     ChangeHashDepth ();
  1127.       else if (stricmp (s, CP[182]) == 0)    /*random*/
  1128.     dither = DITHER;
  1129.       else if (stricmp (s, CP[152]) == 0)    /*easy*/
  1130. #if defined(AMIGA) && defined(LATTICE)    /* no way to interrupt in Lattice */
  1131.         ;            /* yet... */
  1132. #else
  1133.     flag.easy = !flag.easy;
  1134. #endif
  1135.       else if (stricmp (s, CP[143]) == 0)    /*contempt*/
  1136.     SetContempt ();
  1137.       else if (stricmp (s, CP[209]) == 0)    /*xwndw*/
  1138.     ChangeXwindow ();
  1139.       else if (stricmp (s, CP[186]) == 0)    /*rv*/
  1140.     {
  1141.       flag.rv = !flag.rv;
  1142.       UpdateDisplay (0, 0, 1, 0);
  1143.     }
  1144.       else if (stricmp (s, CP[145]) == 0)    /*coords*/
  1145.     {
  1146.       flag.coords = !flag.coords;
  1147.       UpdateDisplay (0, 0, 1, 0);
  1148.     }
  1149.       else if (stricmp (s, CP[193]) == 0)    /*stras*/
  1150.     {
  1151.       flag.stars = !flag.stars;
  1152.       UpdateDisplay (0, 0, 1, 0);
  1153.     }
  1154.       else if (stricmp (s, CP[196]) == 0)    /*test*/
  1155.     {
  1156.       ShowMessage (CP[108]);/*test movelist*/
  1157.       TestSpeed (MoveList, 20000);
  1158.       ShowMessage (CP[107]);/*test capturelist*/
  1159.       TestSpeed (CaptureList, 30000);
  1160.       ShowMessage (CP[85]);/*test score position*/
  1161.       TestPSpeed (ScorePosition, 15000);
  1162.     }
  1163.       else
  1164.       if (stricmp (s, CP[179]) == 0)    /*p*/
  1165.     ShowPostnValues ();
  1166.       else if (stricmp (s, CP[148]) == 0)    /*debug*/
  1167.     DoDebug ();
  1168.     else if (stricmp (s, "Mwpawn") == 0)        /*debug*/
  1169.         DoTable (Mwpawn);
  1170.     else if (stricmp (s, "Mbpawn") == 0)        /*debug*/
  1171.         DoTable (Mbpawn);
  1172.     else if (stricmp (s, "Mwknight") == 0)        /*debug*/
  1173.         DoTable (Mknight[white]);
  1174.     else if (stricmp (s, "Mbknight") == 0)        /*debug*/
  1175.         DoTable (Mknight[black]);
  1176.     else if (stricmp (s, "Mwbishop") == 0)        /*debug*/
  1177.         DoTable (Mbishop[white]);
  1178.     else if (stricmp (s, "Mbbishop") == 0)        /*debug*/
  1179.         DoTable (Mbishop[black]);
  1180.       else
  1181.     {
  1182. #if defined CHESSTOOL
  1183.       normal = (ok = VerifyMove (s, 0, &mv));
  1184. #else
  1185.       ok = VerifyMove (s, 0, &mv);
  1186. #endif
  1187.       if ((ok && mv != hint))
  1188.         {
  1189.           Sdepth = 0;
  1190.           ft = 0;
  1191.         }
  1192.       else
  1193.         Sdepth = 0;
  1194.     }
  1195.     }
  1196.  
  1197.   ElapsedTime (1);
  1198.   if (flag.force)
  1199.     {
  1200.       computer = opponent;
  1201.       opponent = computer ^ 1;
  1202.     }
  1203. #if defined CHESSTOOL || defined XBOARD
  1204. #if defined CHESSTOOL
  1205.   if (normal)
  1206.     if (computer == white)
  1207.       printz ("%d. %s", ++mycnt2, s);
  1208.     else
  1209.       printz ("%d. ... %s", ++mycnt2, s);
  1210. #else
  1211.   printz ("%d. %s\n", ++mycnt2, s);
  1212. #endif
  1213. #ifdef notdef
  1214.   if (flag.post)
  1215.     {
  1216.       register int i;
  1217.  
  1218.       printz (" %6d ", MSCORE);
  1219.       for (i = 1; MV[i] > 0; i++)
  1220.     {
  1221.       algbr ((short) (MV[i] >> 8), (short) (MV[i] & 0xFF), false);
  1222.       printz ("%5s ", mvstr[0]);
  1223.     }
  1224.     }
  1225.   printz ("\n");
  1226. #endif
  1227. #endif /* CHESSTOOL */
  1228.   signal (SIGINT, TerminateSearch);
  1229. #if !(defined(MSDOS) || defined(AMIGA))
  1230.   signal (SIGQUIT, TerminateSearch);
  1231. #endif /* MSDOS */
  1232. }
  1233.  
  1234. void
  1235. ElapsedTime (short int iop)
  1236.  
  1237.  
  1238. /*
  1239.  * Determine the time that has passed since the search was started. If the
  1240.  * elapsed time exceeds the target (ResponseTime+ExtraTime) then set timeout
  1241.  * to true which will terminate the search. iop = 0 calculate et bump ETnodes
  1242.  * iop = 1 calculate et set timeout if time exceeded, calculate et
  1243.  */
  1244.  
  1245. {
  1246. #ifndef MSDOS
  1247.   long nchar;
  1248.   extern int errno;
  1249.   int i;
  1250. #ifdef FIONREAD
  1251.   if (i = ioctl ((int) 0, FIONREAD, &nchar))
  1252.     {
  1253.       perror ("FIONREAD");
  1254.       fprintf (stderr,
  1255.         "You probably have a non-ANSI <ioctl.h>; see README. %d %d %x\n",
  1256.     i, errno, FIONREAD);
  1257.       exit (1);
  1258.     }
  1259.  
  1260.   if (nchar)
  1261.     {
  1262.       if (!flag.timeout)
  1263.     flag.musttimeout = true;
  1264.       flag.bothsides = false;
  1265.     }
  1266. #endif /*FIONREAD*/
  1267. #else
  1268.   if (kbhit ())
  1269.     {
  1270.       if (!flag.timeout)
  1271.     flag.musttimeout = true;
  1272.       flag.bothsides = false;
  1273.     }
  1274. #endif /* MSDOS */
  1275.   et = (time ((long *) 0) - time0) * 100;
  1276.   ETnodes = NodeCnt + ZNODES;
  1277.   if (et < 0)
  1278.     et = 0;
  1279.   if (iop == 1)
  1280.     {
  1281.       if (et > ResponseTime + ExtraTime && Sdepth > MINDEPTH)
  1282.     flag.timeout = true;
  1283.       ETnodes = NodeCnt + ZNODES;
  1284.       time0 = time ((long *) 0);
  1285.     }
  1286. #if !defined NONDSP
  1287. #ifdef QUIETBACKGROUND
  1288.   if (!background)
  1289. #endif /* QUIETBACKGROUND */
  1290.     UpdateClocks ();
  1291. #endif
  1292. }
  1293.  
  1294.  
  1295. void
  1296. ResetTimeControl (void)        /* reset clock using chosen level */
  1297. {
  1298.   if (TCflag)
  1299.     {
  1300.       TimeControl.moves[white] = TimeControl.moves[black] = TCmoves;
  1301.       TimeControl.clock[white] = 6000L * TCminutes + TCseconds * 100;
  1302.       TimeControl.clock[black] = 6000L * TCminutes + TCseconds * 100;
  1303.     }
  1304. }
  1305.  
  1306. void
  1307. SetTimeControl (void)
  1308. {
  1309.   if (TCflag)
  1310.     {
  1311.       TimeControl.moves[white] = TimeControl.moves[black] = TCmoves;
  1312.       TimeControl.clock[white] += 6000L * TCminutes + TCseconds * 100;
  1313.       TimeControl.clock[black] += 6000L * TCminutes + TCseconds * 100;
  1314.     }
  1315.   else
  1316.     {
  1317.       TimeControl.moves[white] = TimeControl.moves[black] = 0;
  1318.       TimeControl.clock[white] = TimeControl.clock[black] = 0;
  1319.     }
  1320.   flag.onemove = (TCmoves == 1);
  1321.   et = 0;
  1322.   ElapsedTime (1);
  1323. }
  1324.